# encoding: utf-8
"""
Redis models
--------------------
"""
from sqlalchemy_utils import Timestamp

from app.extensions import db


class Redis(db.Model, Timestamp):
    """
    Redis  model.
    """
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), unique=True, nullable=False)
    port = db.Column(db.Numeric, nullable=False)

    def __init__(self, id, name, code):
        self.id = id
        self.name = name
        self.code = code

    def __str__(self):
        return (
            "<{class_name}("
            "id={self.id}, "
            "name=\"{self.name}\""
            "port=\"{self.port}\""
            ")>".format(
                class_name=self.__class__.__name__,
                self=self
            )
        )
